<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="clickInspect(record)">检验</a>
        </span>
      </a-table>
    </div>
    <qis-procdetail-value-list ref="modalForm" @ok="modalFormOk" :mainId="mainId"></qis-procdetail-value-list>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import QisProcdetailValueList from './QisProcdetailValueList'

export default {
  name: 'QisProcheadValueList',
  mixins: [JeecgListMixin],
  components: {
    QisProcdetailValueList
  },
  props: {
    mainId: {
      type: String,
      required: false,
      default: ''
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        console.log('监听')
        console.log(val)
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['wordId'] = val
          this.loadData(1)
        }
      }
    }
  },
  data() {
    return {
      description: '过程检验明细',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '工序编号',
          align: 'center',
          dataIndex: 'op'
        },
        {
          title: '工序名称',
          align: 'center',
          dataIndex: 'description'
        },
        {
          title: '检验样本数',
          align: 'center',
          dataIndex: 'sampleNum'
        },
        {
          title: '检验项目数',
          align: 'center',
          dataIndex: 'num'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'typ'
        },
        {
          title: '更新时间',
          align: 'center',
          dataIndex: 'ctime',
          customRender: function(text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/qis/qisProcrecord/opList',
        delete: '/basis/mesStatuswordCfg/deleteMesStatusbitCfg',
        deleteBatch: '/basis/mesStatuswordCfg/deleteBatchMesStatusbitCfg',
        exportXlsUrl: '/basis/mesStatuswordCfg/exportMesStatusbitCfg',
        importUrl: '/basis/mesStatuswordCfg/importMesStatusbitCfg'
      },
      dictOptions: {
        line: [],
        op: [],
        stn: []
      }
    }
  },
  created() {
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`
    }
  },
  methods: {
    clickInspect(val) {
      this.$refs.modalForm.open(val)
    },
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
